<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
      layout:decorate="~{admin/layout}">
<body>

<div  class="content-wrap" layout:fragment="content">
    <main id="content" class="content" role="main">
        <ol class="breadcrumb">
            <li>财务管理</li>
            <li class="active">出库管理</li>
        </ol>
        <div class="row mb-lg">
            <div class="clearfix">
                <ul class="nav nav-tabs pull-xs-left" id="myTab" role="tablist">
                    <li class="nav-item">
                        <a class="nav-link active" id="home-tab" data-toggle="tab" href="#basic" role="tab" aria-controls="basic" aria-expanded="true">出库审批</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" id="profile-tab" data-toggle="tab" href="#assumtion" role="tab" aria-controls="assumtion" aria-expanded="false">已出库</a>
                    </li>
                </ul>
            </div>
            <div class="tab-content mb-lg" id="myTabContent">
                <div role="tabpanel" class="tab-pane active in clearfix" id="basic" aria-labelledby="basic-tab" aria-expanded="true">
                   <div class="widget-body">
                           <!--<button id="submit" class="btn btn-primary" style="background-color: #64bd63;background-color: #64bd63;border-color: #64bd63;">批次生成</button>-->
                           <button id="luru" class="btn btn-primary" style="background-color: #64bd63;background-color: #64bd63;border-color: #64bd63;">审批出库</button>
                        <div class="mt">
                            <div id="priceandlocation" style="display: none">
                                价格: <input type="text" id="price" /><br />
                                去向: <input type="text" id="location" /><br />
                                <input type="submit" id="priceadd">
                            </div>
                            <table class="table table-striped table-hover">
                                <thead>
                                <tr>
                                    <th>
                                        <div class="checkbox abc-checkbox">
                                            <input id="checkbox1" type="checkbox" data-check-all>
                                            <label for="checkbox1"></label>
                                        </div>
                                    </th>
                                    <th>采购地</th>
                                    <th class="hidden-sm-down">出库数量</th>
                                    <th class="hidden-sm-down">树种</th>
                                    <th class="no-sort">胸径/地径</th>
                                    <th class="no-sort">高度</th>
                                    <th class="no-sort">冠幅</th>
                                    <th class="no-sort">是否丛生</th>
                                    <th class="no-sort">枝条数</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="tree:${trees}">
                                    <td>
                                        <div class="checkbox abc-checkbox">
                                            <input class="cc" th:id="${tree.tree_id}" type="checkbox">
                                            <label th:for="${tree.tree_id}"></label>
                                        </div>
                                    </td>
                                    <td th:text="${tree.location}"></td>
                                    <td th:text="${tree.number}"></td>
                                    <td class="hidden-sm-down" th:text="${tree.treeSpecies}"></td>
                                    <td class="hidden-sm-down check" th:text="${tree.chestBreadth}"></td>
                                    <td class="hidden-sm-down check" th:text="${tree.height}"></td>
                                    <td class="hidden-sm-down check" th:text="${tree.crownWidth}"></td>
                                    <td class="hidden-sm-down" th:switch="${tree.clump}">
                                        <span th:case="true">丛生</span>
                                        <span th:case="false"></span>
                                    </td>
                                    <td class="hidden-sm-down check" th:text="${tree.salenumber}"></td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                       <script>
                           checknumber();
                           $(function () {
                               $("#luru").click(function () {
                                   $("#priceandlocation").toggle();
                                   console.log("log");
                                   $("#priceadd").click(function(){
                                       if (confirm("您确定出库吗，一旦确定将无法更改！")) {
                                           var str="";
                                           $(".cc").each(function (i, obj) {
                                               if($(this).is(':checked')){
                                                   str=str+($(this).attr("id")+";");
                                               }
                                           });
                                           if(str==""){
                                               alert('请选择需要录入行！')
                                           }else{
                                               var price=$("#price").val();
                                               var location=$("#location").val();
                                               $.ajax({
                                                   url: "/admin/finance/out/warehouse",
                                                   type: 'POST',
                                                   data:{"treeids":str,"price":price,"location":location},
                                                   async: false,
                                                   success: function (data) {
                                                       console.log(data);
                                                       window.location.reload();
                                                   },
                                                   error: function (xhr) {
                                                       console.log(xhr);
                                                       $("#priceandlocation").hide();
                                                   }
                                               });
                                           };
                                       } else {
                                           return false;
                                       }
                                   });
                               })
                           });
                       </script>
                    </div>
                </div>
                <div class="tab-pane" id="assumtion" role="tabpanel" aria-labelledby="assumtion-tab" aria-expanded="false">
                    <div class="widget-body">
                        <div class="mt">
                            <table class="table table-striped table-hover">
                                <thead>
                                <tr>
                                    <th>采购地</th>
                                    <th>去向</th>
                                    <th class="hidden-sm-down">出库数量</th>
                                    <th class="hidden-sm-down">树种</th>
                                    <th class="no-sort">胸径/地径</th>
                                    <th class="no-sort">高度</th>
                                    <th class="no-sort">冠幅</th>
                                    <th class="no-sort">是否丛生</th>
                                    <th class="no-sort">枝条数</th>
                                    <th class="no-sort">出库时间</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="tree:${trees1}">
                                    <td th:text="${tree.location}"></td>
                                    <td th:text="${tree.direction}"></td>
                                    <td th:text="${tree.number}"></td>
                                    <td class="hidden-sm-down" th:text="${tree.treeSpecies}"></td>
                                    <td class="hidden-sm-down check" th:text="${tree.chestBreadth}"></td>
                                    <td class="hidden-sm-down check" th:text="${tree.height}"></td>
                                    <td class="hidden-sm-down check" th:text="${tree.crownWidth}"></td>
                                    <td class="hidden-sm-down" th:switch="${tree.clump}">
                                        <span th:case="true">丛生</span>
                                        <span th:case="false">&nbsp;</span>
                                    </td>
                                    <td class="hidden-sm-down" th:text="${tree.salenumber}"></td>
                                    <td class="hidden-sm-down" th:text="${tree.createtime}"></td>
                                </tr>
                                </th:each>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
</div>
</body>
</html>